package com.wc.AlgoOJ.DS0403;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congege
 * @Description 求众
 * http://43.138.190.70:8888/p/DS0403
 * @Date Created in 2023/12/3-12:11
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        // 存储元数据
        int[] array = new int[n];
        // 存储答案
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        Arrays.sort(array);
        // 当前重复数字的Id
        int repeatIdx = 0;
        // 当前重复数出现的次数
        int cnt = 1;
        // 当前重复数出现的最大次数
        int maxCnt = -1;
        // 答案上的数组位置
        int ansIdx = 0;

        for (int i = 1; i < n; i++) {
            // 比较前面重复数
            if (array[i] == array[repeatIdx]) {
                cnt++;
            } else {
                if (cnt >= maxCnt) {
                    if (cnt > maxCnt) {
                        maxCnt = cnt;
                        ansIdx = 0;
                    }

                    ans[ansIdx++] = array[repeatIdx];
                }
                cnt = 1;
                repeatIdx = i;
            }
        }

        if (cnt >= maxCnt){
            if (cnt > maxCnt) {
                maxCnt = cnt;
                ansIdx = 0;
            }
            ans[ansIdx++] = array[repeatIdx];
        }

        StringBuffer ansStr = new StringBuffer();
        ansStr.append(ans[0]);
        for (int i = 1; i < ansIdx; i++) {
            ansStr.append(' ');
            ansStr.append(ans[i]);
        }
        System.out.println(ansStr);
    }
}
